<?php
/**
 * SellerGroup.php
 *
 * @copyright  2023 opencart.cn - All Rights Reserved
 * @link       http://www.guangdawangluo.com
 * @author     TL <mengwb@opencart.cn>
 * @created    2023-04-18 19:35:35
 * @modified   2023-04-18 19:35:35
 */

namespace Beike\Seller\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;

class SellerGroup extends Base
{
    use HasFactory;

    protected $fillable = ['fee_show_flat', 'fee_show_percent', 'fee_sale_flat', 'fee_sale_percent', 'product_count', 'position'];

    public function description()
    {
        $description = $this->hasOne(SellerGroupDescription::class)->where('locale', locale());
        if (!$description->count()) {
            $description = $this->hasOne(SellerGroupDescription::class)->limit(1);
        }
        return $description;
    }

    public function descriptions()
    {
        return $this->hasMany(SellerGroupDescription::class);
    }
}
